From: Georges Basile Stavracas Neto Date: Thu, 21 Nov 2019 20:57:17 +0000 (-0300) Subject: allView, frequentView: Only create icons when necessary X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~781^2^2~399 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=910037f014355ee9680c45f82a4aac2891c4074f;p=gnome-shell.git allView, frequentView: Only create icons when necessary The views (AllView and FrequentView) build a list of all applications they contain. BaseView then diffs between what's currently added, and what needs to be added, and removed. This approach has a problem though: creating an AppIcon or a FolderIcon connects to various signals, and we confuse the garbage collector. When building the list of applications, instead of always creating new icons, try to use already existing icons first. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1610 Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1694 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 9a7b64521..838fef607 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -491,10 +491,15 @@ var AllView = GObject.registerClass({ let favoritesWritable = global.settings.is_writable('favorite-apps'); apps.forEach(appId => { - let app = appSys.lookup_app(appId); + let icon = this._items[appId]; + if (!icon) { + let app = appSys.lookup_app(appId); + + icon = new AppIcon(app, { + isDraggable: favoritesWritable, + }); + } - let icon = new AppIcon(app, - { isDraggable: favoritesWritable }); newApps.push(icon); }); @@ -947,8 +952,12 @@ class FrequentView extends BaseAppView { for (let i = 0; i < mostUsed.length; i++) { if (!mostUsed[i].get_app_info().should_show()) continue; - let appIcon = new AppIcon(mostUsed[i], - { isDraggable: favoritesWritable }); + let appIcon = this._items[mostUsed[i].get_id()]; + if (!appIcon) { + appIcon = new AppIcon(mostUsed[i], { + isDraggable: favoritesWritable, + }); + } apps.push(appIcon); }